package com.example.dream.learnandroid;

import android.content.Intent;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.example.dream.learnandroid.criminalIntent.CrimeActivity;
import com.example.dream.learnandroid.criminalIntent.CrimeListActivity;
import com.example.dream.learnandroid.geoquiz.QuizActivity;

public class MainActivity extends AppCompatActivity {
    private static String TAG = "MainActivity";

    private Button mBtnTextView;
    private Button mBtnButton;
    private Button mBtnEditView;
    private Button mBtnRadio;
    private Button mBtnCheckBox;
    private Button mBtnImageView;
    private Button mBtnQuiz;
    private Button mBtnCrimeList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mBtnTextView = findViewById(R.id.btn_textview);
        mBtnButton = findViewById(R.id.btn_button);
        mBtnEditView = findViewById(R.id.btn_editText);
        mBtnRadio    = findViewById(R.id.btn_radio);
        mBtnCheckBox = findViewById(R.id.btn_checkbox);
        mBtnImageView = findViewById(R.id.btn_imageview);
        mBtnQuiz      = findViewById(R.id.btn_quiz);
        mBtnCrimeList = findViewById(R.id.btn_crimeList);
        setListener();

    }

    private void setListener(){
        OnClick onClick = new OnClick();
        mBtnTextView.setOnClickListener(onClick);
        mBtnButton.setOnClickListener(onClick);
        mBtnEditView.setOnClickListener(onClick);
        mBtnRadio.setOnClickListener(onClick);
        mBtnCheckBox.setOnClickListener(onClick);
        mBtnImageView.setOnClickListener(onClick);
        mBtnQuiz.setOnClickListener(onClick);
        mBtnCrimeList.setOnClickListener(onClick);
    }
    private class OnClick implements View.OnClickListener{

        @Override
        public void onClick(View view) {
            Intent intent = null;
            switch (view.getId()){
                case R.id.btn_textview:
                    //跳转到 TextView Activity
                    intent = new Intent(MainActivity.this, TextViewActivity.class);
                    break;
                case R.id.btn_button:
                    //跳转到 ButtonActivity
                    intent = new Intent(MainActivity.this, ButtonActivity.class);
                    break;
                case R.id.btn_editText:
                    //跳转到 EditText Activity
                    intent = new Intent(MainActivity.this, EditTextActivity.class);
                    break;
                case R.id.btn_radio:
                    //跳转到 TextView Activity
                    intent = new Intent(MainActivity.this, RadioButtonActivity.class);
                    break;
                case R.id.btn_checkbox:
                    //调转到
                    intent = new Intent(MainActivity.this, CheckBoxActivity.class);
                    break;
                case R.id.btn_imageview:
                    intent = new Intent(MainActivity.this, ImageViewActivity.class);
                    break;
                case R.id.btn_quiz:
                    intent = new Intent(MainActivity.this, QuizActivity.class );
                    break;
                case R.id.btn_crimeList:
                    intent = new Intent(MainActivity.this, CrimeListActivity.class);
            }
            startActivity(intent);
        }
    }
}
